<?php
    include_once ("MySql.php");
    include_once ("../entity/Usuario.php");
    
    class UsuarioDA extends dal{
        public function UsuarioDA(){
            parent::dal();
        }
        public function numeroRegistro($login,$nombre){
            $sql = "CALL SGLSS_CUENTA_USUARIO('$login','$nombre')";
            $result = parent::ejecutar($sql);
            $num_row=0;
            while($fila = mysqli_fetch_object($result)){
                $num_row= $fila->num_row;
            }
            return $num_row;
        }
        public function BuscarSearch($entity, $start , $limit,$sidx,$sord){
            $sql = "CALL SGLSS_USUARIO_SEARCH('$entity->usu_login',"
                    . "'$entity->per_nombre_completo',"
                    . "'$start' ,"
                    . "'$limit',"
                    . "'$sidx',"
                    . "'$sord')";
            $result = parent::ejecutar($sql);
            while($fila = mysqli_fetch_object($result)){
                $obj = new Usuario();
                $obj->usu_codigo = $fila->usu_codigo;
                $obj->usu_login = $fila->usu_login;
                $obj->usu_cargo = $fila->usu_cargo;
                $obj->usu_estado = "Inactivo";
                if($fila->usu_estado == 1){
                    $obj->usu_estado = "Activo";
                }
                $obj->per_codigo = $fila->per_codigo;
                $obj->per_nombre_completo = $fila->per_nombre_completo;
                $obj->per_sexo = "Femenino";
                if($fila->per_sexo == "M"){
                    $obj->per_sexo = "Masculino";
                }
                $obj->per_fecha_nacimiento = $fila->per_fecha_nacimiento;
                $obj->per_dni = $fila->per_dni;
                $obj->per_direccion = $fila->per_direccion;
                $obj->per_email = $fila->per_email;
                $usuario[] = $obj;
            }
            return $usuario;
        }
    }
?>